import request from '@/utils/request'

/**
 * 获取订单列表
 * @param {Object} params - 查询参数
 * @returns {Promise} 返回订单列表数据
 */
export const getOrderList = (params) => {
  return request({
    url: '/admin/orders',
    method: 'get',
    params
  })
}

/**
 * 获取订单详情
 * @param {number} id - 订单ID
 * @returns {Promise} 返回订单详情
 */
export const getOrderDetail = (id) => {
  return request({
    url: `/admin/orders/${id}`,
    method: 'get'
  })
}

/**
 * 更新订单状态
 * @param {number} id - 订单ID
 * @param {Object} data - 更新数据
 * @returns {Promise} 返回更新结果
 */
export const updateOrderStatus = (id, data) => {
  return request({
    url: `/admin/orders/${id}/status`,
    method: 'put',
    data
  })
}

/**
 * 删除订单
 * @param {number} id - 订单ID
 * @returns {Promise} 返回删除结果
 */
export const deleteOrder = (id) => {
  return request({
    url: `/admin/orders/${id}`,
    method: 'delete'
  })
}

// 获取订单统计数据
export function getOrderStats(params) {
  return request({
    url: '/api/admin/orders/stats',
    method: 'get',
    params
  })
}

// 导出订单数据
export function exportOrders(params) {
  return request({
    url: '/api/admin/orders/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 更新订单备注
export function updateOrderRemark(id, remark) {
  return request({
    url: `/api/admin/orders/${id}/remark`,
    method: 'put',
    data: { remark }
  })
}

// 获取订单物流信息
export function getOrderLogistics(id) {
  return request({
    url: `/api/admin/orders/${id}/logistics`,
    method: 'get'
  })
}

// 更新订单物流信息
export function updateOrderLogistics(id, data) {
  return request({
    url: `/api/admin/orders/${id}/logistics`,
    method: 'put',
    data
  })
}

// 批量发货
export function batchShipOrders(data) {
  return request({
    url: '/api/admin/orders/batch/ship',
    method: 'post',
    data
  })
} 